package com.ftl.games;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;
import android.widget.Toast;

import com.facebook.android.R;

public class FormUser extends Activity {
	
	private static String	_uid;
	private static boolean	_esAdmin;
	private static String	_nombreImagen;
	
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        
        setContentView(R.layout.form);
        
        Bundle paramsRecibos = getIntent().getExtras();
        FormUser._esAdmin = paramsRecibos.getBoolean("esAdmin");
        FormUser._uid = paramsRecibos.getString("uid");
        FormUser._nombreImagen = paramsRecibos.getString("nombreImagen");
        
        TextView bases = (TextView) findViewById(R.id.lblAcepto);
    	bases.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
            	Intent i = new Intent(FormUser.this,Bases.class);               
            	startActivityForResult(i,10);  
            }
    	});
        
        this.AceptarCancelar();
        
        
	}
	protected void AceptarCancelar(){
		Button btnFoto = (Button) findViewById(R.id.btnForm);
        
        btnFoto.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
            	CheckBox chkAcepto = (CheckBox) findViewById(R.id.chkAcepto);
                    
            	if(chkAcepto.isChecked()){
	            	
	            	TextView txtNombre = (TextView) findViewById(R.id.txtNombre);
	                TextView txtApellido = (TextView) findViewById(R.id.txtApellido);
	                TextView txtEmail = (TextView) findViewById(R.id.txtEmail);
	                TextView txtDNI = (TextView) findViewById(R.id.txtDNI);
	                
	                
	                Bundle params = new Bundle();
	                params.putString	("nombre"		, txtNombre.getText().toString());
	                params.putString	("apellido"		, txtApellido.getText().toString());
	                params.putString	("email"		, txtEmail.getText().toString());
	                params.putString	("dni"		    , txtDNI.getText().toString());
	          
	                params.putString	("uid"			, FormUser._uid);
	                params.putBoolean	("esAdmin"		, FormUser._esAdmin);
	                //params.putString	("ImagenUri"	, paramsRecibos.getString("ImagenUri"));
	                params.putString	("nombreImagen"	, FormUser._nombreImagen);
	                
	                Config.cambiarDePantalla(Config.PANTALLA_PUBLICAR_FOTO, params, FormUser.this);
            	}else{
            		Toast toast1 =  Toast.makeText(getApplicationContext(), "Tenes que aceptar para continuar", Toast.LENGTH_SHORT);           
            		toast1.show(); 
            	}
            }
    	});
        
        Button btnFotoCancel = (Button) findViewById(R.id.btnFormCancel);
        
        btnFotoCancel.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
            	setContentView(R.layout.gracias);
            }
        });
		
	}
	
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {   
		setContentView(R.layout.form);
		
		this.AceptarCancelar();
    }
}
